package com.jinsi.service.tang.iml;

import com.jinsi.constant.TangConstant;
import com.jinsi.mapper.tang.ProductReviewMapper;
import com.jinsi.pojo.Comment;
import com.jinsi.service.tang.ProductReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 商品评论
 * @author 唐文博
 * @Date 2022-09-13
 */
@Service
@Transactional
public class ProductReviewServiceImpl implements ProductReviewService {
    @Autowired
    private ProductReviewMapper productReviewMapper;

    /**
     * 查看商品历史评论人数和次数
     * @return
     */
    @Override
    @Transactional(readOnly = true)
    public int getProductReview() {
        return productReviewMapper.getProductReview(TangConstant.COMMENT_COMMODITY);
    }

    /**
     * 查看今日商品评论人数和次数
     * @return
     */
    @Override
    @Transactional(readOnly = true)
    public int getProductToday() {
        return productReviewMapper.getProductToday(TangConstant.COMMENT_COMMODITY);
    }

    /**
     * 查看评论列表的成员账号，昵称，所属商品，发言时间，发言内容
     * @return
     */
    @Override
    @Transactional(readOnly = true)
    public List<Comment> getReview() {
        return productReviewMapper.getReview(TangConstant.COMMENT_COMMODITY);
    }

    /**
     * 查看正常评论列表的成员账号及信息（已通过）
     * @return
     */
    @Override
    @Transactional(readOnly = true)
    public List<Comment> getReviewNormal(Integer status) {
        return productReviewMapper.getReviewNormal(status,TangConstant.COMMENT_COMMODITY);
    }

    /**
     * 修改成已拦截状态 //状态 1已通过 2已拦截 3已删除',
     * @param id
     * @param status
     */
    @Override
    public void updateReviewBlocked(Integer id, Integer status) {
        productReviewMapper.updateReviewBlocked(id,status);
    }
}